**************************************************************************************************
****** Likeminded? Congruence Between Political Elites and their Voters Regarding ****************
******                  Policy Choices in Swiss-EU Relations                      ****************
**************************************************************************************************
***************** ARTICLE FOR SPSR SPECIAL ISSUE ON THE SWISS ELECTIONS 2019 *********************
*****************            Author: Lukas Lauener                           *********************
*****************          Last modified: 06/05/2022                         *********************
**************************************************************************************************

*****************************************************************************************
**** PART 1: APPEND CANDIDATE AND VOTER DATASETS ****************************************
*****************************************************************************************

****************************************************************
*** Panel Survey: "Selects2019_Panel.v1.0.dta"               ***
*** Candidate Survey: "Selects2019_CandidateSurvey_v1.0.dta" ***
****************************************************************

use "...\Selects2019_Panel.v1.0.dta", clear

append using "...\Selects2019_CandidateSurvey_v1.0.dta"

save "...\voters_candidates_combined.dta", replace

*****************************************************************************************
**** PART 2: SOME RECODES ***************************************************************
*****************************************************************************************

*** open combined "voter-candidate-data"
use "...\voters_candidates_combined.dta", clear

gen lang=lingreg_sample
recode lang (4=1)

gen candidate=.
recode candidate (.=1) if id==.
recode candidate (.=0) if id!=.
lab def candidate 0 "voters" 1 "candidates"
lab val candidate candidate

gen party=.

tab W2_3_f11800main6
gen W2_3_f11800main6_rec=W2_3_f11800main6
tab W2_3_f11800main6_rec
replace party=W2_3_f11800main6_rec if cand==0

tab T9a
gen T9a_rec=T9a
recode T9a_rec (1=2) (2=3) (3=5) (4=1) (5=6) (6=4) (20 97=7)
tab T9a_rec
replace party=T9a_rec if cand==1

lab def party 1 "SVP" 2 "FDP" 3 "CVP" 4 "GLP" 5 "SP" 6 "GPS" 7 "others"
lab val party party
tab party

gen part=.
recode part (.=1) if W2_f10701==1
recode part (.=1) if W3_f11100==4
recode part (.=0) if W3_f11100==1
recode part (.=0) if W3_f11100==2
recode part (.=0) if W3_f11100==3
tab part

gen income_ae=W1_f28910
label variable income_ae "Einkommen nach Haushaltsgrösse"
recode income_ae (1=1000) (2=2500) (3=3500) (4=4500) (5=5500) (6=6500) (7=7500) (8=8500) (9=9500) (10=10500) (11=11500) (12=12500) (13=13500) (14=14500) (15=15000) (*=.)
replace income_ae=income_ae/sqrt(hhsize_sample)
label variable income_ae "Äquivalenzeinkommen (mean(HE)/sqrt(HH))"
xtile pct = income_ae, n(4)
label variable pct "Einkommensquartile"
tab pct

tab W1_f21310
gen educ_cat=W1_f21310
recode educ_cat (-99 14=.)
recode educ_cat (1 2 3 4 5=1)
recode educ_cat (6 7 8 9 10=2)
recode educ_cat (11 12 13=3)
lab var educ_cat "education category"
lab def educ_cat 1 "low" 2 "middle" 3 "high"
lab val educ_cat educ_cat

gen educ=W1_f21310
recode educ (14=.)
lab var educ "education"
tab educ

tab W1_f15200
codebook W1_f15200
gen lrsp_cat=W1_f15200
recode lrsp_cat (0 1 2=1)
recode lrsp_cat (3 4=2)
recode lrsp_cat (5=3)
recode lrsp_cat (6 7=4)
recode lrsp_cat (8 9 10=5)
recode lrsp_cat (98=.)

gen lrsp_cont=W1_f15200
recode lrsp_cont (98=.)

tab W1_f10100
gen polin=W1_f10100
recode polin (1=4) (2=3) (3=2) (4=1)
tab polin

egen know=rowtotal(W2_f15900rec W2_f16310rec W2_f16312rec W2_f16313rec)
recode know (0 1 2 3 4 5=.) if W2_f15900rec==. & W2_f16310rec==. & W2_f16312rec==. & W2_f16313rec==.
tab know
browse W2_f15900rec W2_f16310rec W2_f16312rec W2_f16313rec know

tab W1_f14070
gen close=W1_f14070
recode close (1=3) (3=1)
tab close

* create party dummies
tab W2_3_f11800main6

gen SVP=.
recode SVP (.=1) if W2_3_f11800main6==1
recode SVP (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==3 | W2_3_f11800main6==4 | W2_3_f11800main6==5 | W2_3_f11800main6==6 | W2_3_f11800main6==7
tab SVP

gen FDP=.
recode FDP (.=1) if W2_3_f11800main6==2
recode FDP (.=0) if W2_3_f11800main6==1 | W2_3_f11800main6==3 | W2_3_f11800main6==4 | W2_3_f11800main6==5 | W2_3_f11800main6==6 | W2_3_f11800main6==7
tab FDP

gen CVP=.
recode CVP (.=1) if W2_3_f11800main6==3
recode CVP (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==1 | W2_3_f11800main6==4 | W2_3_f11800main6==5 | W2_3_f11800main6==6 | W2_3_f11800main6==7
tab CVP

gen GLP=.
recode GLP (.=1) if W2_3_f11800main6==4
recode GLP (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==3 | W2_3_f11800main6==1 | W2_3_f11800main6==5 | W2_3_f11800main6==6 | W2_3_f11800main6==7
tab GLP

gen SP=.
recode SP (.=1) if W2_3_f11800main6==5
recode SP (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==3 | W2_3_f11800main6==4 | W2_3_f11800main6==1 | W2_3_f11800main6==6 | W2_3_f11800main6==7
tab SP

gen GPS=.
recode GPS (.=1) if W2_3_f11800main6==6
recode GPS (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==3 | W2_3_f11800main6==4 | W2_3_f11800main6==5 | W2_3_f11800main6==1 | W2_3_f11800main6==7
tab GPS

gen others=.
recode others (.=1) if W2_3_f11800main6==7
recode others (.=0) if W2_3_f11800main6==2 | W2_3_f11800main6==3 | W2_3_f11800main6==4 | W2_3_f11800main6==5 | W2_3_f11800main6==6 | W2_3_f11800main6==1
tab others

*****************************************************************************************
**** PART 3: EUROPEAN INTEGRATION POLICIES **********************************************
*****************************************************************************************

*** limits on immigration vs. bilaterals
* candidates
tab S17
gen tobilateral_C=S17
recode tobilateral_C (1=2) (2=1) (3=-1) (4=-2)
tab S17 tobilateral_C
tab tobilateral_C
gen disfrom0_tobilateral_C=abs(tobilateral_C)
tab disfrom0_tobilateral_C
* voters
tab W1_f15655
gen tobilateral_V=W1_f15655
recode tobilateral_V (1=-2) (2=-1) (3=1) (4=2)
tab W1_f15655 tobilateral_V
gen disfrom0_tobilateral_V=abs(tobilateral_V)

*** cohesion billion
* candidates
tab C10
gen cohesion_C=C10
recode cohesion_C (1=2) (2=1) (3=-1) (4=-2)
tab C10 cohesion_C
gen disfrom0_cohesion_C=abs(cohesion_C)
* voters
tab W1_f15642
gen cohesion_V=W1_f15642 
recode cohesion_V (1=2) (2=1) (3=-1) (4=-2)
tab W1_f15642 cohesion_V
gen disfrom0_cohesion_V=abs(cohesion_V)

*** flanking measures vs. institutional framework agreement
* candidates
tab C9
gen toinsta_C=C9
recode toinsta_C (1=2) (2=1) (3=-1) (4=-2)
tab C9 toinsta_C
gen disfrom0_toinsta_C=abs(toinsta_C)
* voters
tab W1_f15641
gen toinsta_V=W1_f15641 
recode toinsta_V (1=2) (2=1) (3=-1) (4=-2)
tab W1_f15641 toinsta_V
gen disfrom0_toinsta_V=abs(toinsta_V)

*** EU membership
* candidates
tab S57
gen EUmember_C=S57
recode EUmember_C (1=-2) (2=-1) (3=1) (4=2)
tab S57 EUmember_C
gen disfrom0_EUmember_C=abs(EUmember_C)
* voters
tab W1_f15430
gen EUmember_V=W1_f15430 
recode EUmember_V (1=2) (2=1) (3=0) (4=-1) (5=-2)
tab W1_f15430 EUmember_V
gen disfrom0_EUmember_V=abs(EUmember_V)

*****************************************************************************************
**** PART 4: POLITICAL KNOWLEDGE AND INTEREST *******************************************
*****************************************************************************************

tab tobilateral_V if W2_3_f11800main6!=. 
tab tobilateral_V know if W2_3_f11800main6!=.
tab tobilateral_V W2_f10100 if W2_3_f11800main6!=.

tab cohesion_V if W2_3_f11800main6!=.
tab cohesion_V know if W2_3_f11800main6!=.
tab cohesion_V W2_f10100 if W2_3_f11800main6!=.

tab toinsta_V if W2_3_f11800main6!=.
tab toinsta_V know if W2_3_f11800main6!=.
tab toinsta_V W2_f10100 if W2_3_f11800main6!=.

tab EUmember_V if W2_3_f11800main6!=.
tab EUmember_V know if W2_3_f11800main6!=.
tab EUmember_V W2_f10100 if W2_3_f11800main6!=.


* political knowledge question --> those who answered 3 or 4 (out of 4) knowledge questions correctly (=1)
* others (=0)
tab know if W2_3_f11800main6!=.
gen PK=.
recode PK (.=1) if know==3 | know==4
recode PK (.=0) if know==0 | know==1 | know==2
tab PK if W2_3_f11800main6!=.

* political interest question --> those who are rather or very interested in politics (=1)
* others (=0)
tab W2_f10100 if W2_3_f11800main6!=.
gen INT=.
recode INT (.=0) if W2_f10100==3 | W2_f10100==4
recode INT (.=1) if W2_f10100==1 | W2_f10100==2
tab INT if W2_3_f11800main6!=.

tab know W2_f10100 if W2_3_f11800main6!=.
tab PK INT if W2_3_f11800main6!=.

* combined variable: political knowledge and interest
gen knowint=.
recode knowint (.=0) if INT==0 & PK==0
recode knowint (.=0) if INT==0 & PK==1
recode knowint (.=0) if INT==1 & PK==0
recode knowint (.=1) if INT==1 & PK==1
tab knowint if W2_3_f11800main6!=.

* N (knowledgeable and interested voters --> for appendix)
tab knowint tobilateral_V if party!=. 
tab knowint cohesion_V if party!=. 
tab knowint toinsta_V if party!=. 
tab knowint EUmember_V if party!=. 

tab knowint tobilateral_V if party==1
tab knowint cohesion_V if party==1
tab knowint toinsta_V if party==1
tab knowint EUmember_V if party==1

tab knowint tobilateral_V if party==2
tab knowint cohesion_V if party==2
tab knowint toinsta_V if party==2
tab knowint EUmember_V if party==2

tab knowint tobilateral_V if party==3
tab knowint cohesion_V if party==3
tab knowint toinsta_V if party==3
tab knowint EUmember_V if party==3

tab knowint tobilateral_V if party==4
tab knowint cohesion_V if party==4
tab knowint toinsta_V if party==4
tab knowint EUmember_V if party==4

tab knowint tobilateral_V if party==5
tab knowint cohesion_V if party==5
tab knowint toinsta_V if party==5
tab knowint EUmember_V if party==5

tab knowint tobilateral_V if party==6
tab knowint cohesion_V if party==6
tab knowint toinsta_V if party==6
tab knowint EUmember_V if party==6

*****************************************************************************************
**** PART 5: EMPIRICAL ANALYSES *********************************************************
*****************************************************************************************

* Cronbach's alpha --> maybe also look at original variables instead of these recoded ones 
alpha tobilateral_V cohesion_V toinsta_V EUmember_V if party!=.
alpha tobilateral_C cohesion_C toinsta_C EUmember_C

alpha tobilateral_V cohesion_V toinsta_V EUmember_V, std item
alpha tobilateral_C cohesion_C toinsta_C EUmember_C, std item

*factor analysis:
factor tobilateral_C cohesion_C toinsta_C EUmember_C, blanks(.30)
factor tobilateral_V cohesion_V toinsta_V EUmember_V, blanks(.30)

* How many voters (from the total of 4009 for the EU membership question (EUmember_V)) did not participate in W2?
tab W2_mobile if EUmember_V!=. & party!=.
tab W2_mobile EUmember_V if party!=.
tab W2_spr EUmember_V if party!=.

********************************************************************************
* Hypothesis 1: Are the elites significantly more EU-integrationist than voters?
********************************************************************************

* bilateral
sum tobilateral_C [aweight=T16]
sum tobilateral_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2010 1.193109 1.419615 3973 .4151731 1.441772

* cohesion
sum cohesion_C [aweight=T16]
sum cohesion_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2082 .3575204 1.543801 3950 .0532621 1.444404

* institutional agreement
sum toinsta_C [aweight=T16]
sum toinsta_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2057 -.246413 1.518217 3885 -.3420576 1.29838

* EU membership
sum EUmember_C [aweight=T16]
sum EUmember_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2009 -1.191785 1.296727 4009 -.7236237 1.150368

********************************************************************************
* Hypothesis 2: Are the elites significantly more distant from 0 (neither in 
* favour of nor against European integration policy) than voters?
********************************************************************************

sum disfrom0_tobilateral_C [aweight=T16]
sum disfrom0_tobilateral_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2010 1.812605 .3903255 3973 1.416851 .4930998

sum disfrom0_cohesion_C [aweight=T16]
sum disfrom0_cohesion_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2082	1.503332	.500109 3950	1.362871	.4808889

sum disfrom0_toinsta_C [aweight=T16]
sum disfrom0_toinsta_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2057	1.454861	.4980794 3885	1.267454	.442688

sum disfrom0_EUmember_C [aweight=T16]
sum disfrom0_EUmember_V if W2_3_f11800main6!=. [aweight=weight_p]
ttesti 2009	1.700339	.4582235 4009	1.162671	.7035392

** The above overall results and the following results for the political parties are the results displayed in Table 1 of the article
** Notes: 
** - All detailed descriptive results are saved in the Excel file named "Hypotheses testing.xlsx"
** - All calculations under "*knowint" are done to examine whether politically interested and knowledgeable voters have greater 
**   congruence with their party elites than those less politically interested and knowledgeable (see Online Appendix)

*** PROCEDURE (REPEATED FOR EACH EUROPEAN INTEGRATION POLICY)
*** 1) calculate the mean positions (candidates/voters)
*** 2) calculate the mean distance to centre position (candidates/voters)
*** 3) compare areas under the two cumulative distribution functions (candidates/voters)

**************************************
* LIMITS ON IMMIGRATION VS. BILATERALS
**************************************

* rearrange variable (original categories, same direction for C and V)
tab W1_f15655
tab S17
gen S17_rec=S17
recode S17_rec (1=4) (2=3) (3=2) (4=1)
tab S17_rec

gen tobilateral=.
replace tobilateral=W1_f15655 if W2_3_f11800main6!=. & cand==0
replace tobilateral=S17_rec if cand==1
tab tobilateral cand

*overall
histogram tobilateral if cand==0, normal percent
cumul tobilateral if cand==0 [aweight=weight_p], gen(overall_v) equal
line overall_v tobilateral if cand==0, sort

histogram tobilateral if cand==1, normal percent
cumul tobilateral if cand==1 [aweight=T16], gen (overall_c) equal
line overall_c tobilateral if cand==1, sort

twoway histogram tobilateral, discrete freq by(cand, title("Overall")) 
twoway line overall_c overall_v tobilateral, sort lpattern(dash solid) title("Overall")

integ(overall_c tobilateral) 
integ(overall_v tobilateral) 
*congruence: |0.98091938-1.6509507|=0.670031

*knowint
cumul tobilateral if cand==0 & knowint==0 [aweight=weight_p], gen(overall_v_0) equal
integ(overall_v_0 tobilateral) 
cumul tobilateral if cand==0 & knowint==1 [aweight=weight_p], gen(overall_v_1) equal
integ(overall_v_1 tobilateral) 

*Histogram "bilateral treaties" across all parties
twoway histogram tobilateral, discrete freq by(party cand) 

*SVP
sum tobilateral_C if T9a==4 
sum tobilateral_V if W2_3_f11800main6==1
ttesti 175	-1.571429	0.8538525 675	-0.8474074	1.297843

histogram tobilateral if cand==0 & party==1, normal percent
cumul tobilateral if cand==0 & party==1, gen(tobilateral_svp_v) equal
line tobilateral_svp_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==1, normal percent
cumul tobilateral if cand==1 & party==1, gen(tobilateral_svp_c) equal
line tobilateral_svp_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==1, discrete freq by(cand, title("SVP"))
twoway line tobilateral_svp_c tobilateral_svp_v tobilateral, sort lpattern(dash solid) title("SVP") ylabel(0(.2)1)

integ(tobilateral_svp_c tobilateral)
integ(tobilateral_svp_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==1 & knowint==0, gen(tobilateral_svp_v_0) equal
integ(tobilateral_svp_v_0 tobilateral)
cumul tobilateral if cand==0 & party==1 & knowint==1, gen(tobilateral_svp_v_1) equal
integ(tobilateral_svp_v_1 tobilateral)

*FDP
sum tobilateral_C if T9a==1
sum tobilateral_V if W2_3_f11800main6==2
ttesti 214	1.61215	0.8470008 649	0.7365177	1.243467

histogram tobilateral if cand==0 & party==2, normal percent
cumul tobilateral if cand==0 & party==2, gen(tobilateral_fdp_v) equal
line tobilateral_fdp_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==2, normal percent
cumul tobilateral if cand==1 & party==2, gen(tobilateral_fdp_c) equal
line tobilateral_fdp_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==2, discrete freq by(cand, title("FDP"))
twoway line tobilateral_fdp_c tobilateral_fdp_v tobilateral, sort lpattern(dash solid) title("FDP")

integ(tobilateral_fdp_c tobilateral)
integ(tobilateral_fdp_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==2 & knowint==0, gen(tobilateral_fdp_v_0) equal
integ(tobilateral_fdp_v_0 tobilateral)
cumul tobilateral if cand==0 & party==2 & knowint==1, gen(tobilateral_fdp_v_1) equal
integ(tobilateral_fdp_v_1 tobilateral)

*CVP
sum tobilateral_C if T9a==2
sum tobilateral_V if W2_3_f11800main6==3
ttesti 326	1.555215	0.8530599 360	0.55	1.265682

histogram tobilateral if cand==0 & party==3, normal percent
cumul tobilateral if cand==0 & party==3, gen(tobilateral_cvp_v) equal
line tobilateral_cvp_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==3, normal percent
cumul tobilateral if cand==1 & party==3, gen(tobilateral_cvp_c) equal
line tobilateral_cvp_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==3, discrete freq by(cand, title("CVP"))
twoway line tobilateral_cvp_c tobilateral_cvp_v tobilateral, sort lpattern(dash solid) title("CVP")

integ(tobilateral_cvp_c tobilateral)
integ(tobilateral_cvp_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==3 & knowint==0, gen(tobilateral_cvp_v_0) equal
integ(tobilateral_cvp_v_0 tobilateral)
cumul tobilateral if cand==0 & party==3 & knowint==1, gen(tobilateral_cvp_v_1) equal
integ(tobilateral_cvp_v_1 tobilateral)

*GLP
sum tobilateral_C if T9a==6
sum tobilateral_V if W2_3_f11800main6==4
ttesti 238	1.815126	0.636 433	0.9838337	1.189155

histogram tobilateral if cand==0 & party==4, normal percent
cumul tobilateral if cand==0 & party==4, gen(tobilateral_glp_v) equal
line tobilateral_glp_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==4, normal percent
cumul tobilateral if cand==1 & party==4, gen(tobilateral_glp_c) equal
line tobilateral_glp_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==4, discrete freq by(cand, title("GLP"))
twoway line tobilateral_glp_c tobilateral_glp_v tobilateral, sort lpattern(dash solid) title("GLP")

integ(tobilateral_glp_c tobilateral) 
integ(tobilateral_glp_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==4 & knowint==0, gen(tobilateral_glp_v_0) equal
integ(tobilateral_glp_v_0 tobilateral)
cumul tobilateral if cand==0 & party==4 & knowint==1, gen(tobilateral_glp_v_1) equal
integ(tobilateral_glp_v_1 tobilateral)

*SP
sum tobilateral_C if T9a==3
sum tobilateral_V if W2_3_f11800main6==5
ttesti 304	1.940789	0.275119 769	1.209363	0.973137

histogram tobilateral if cand==0 & party==5, normal percent
cumul tobilateral if cand==0 & party==5, gen(tobilateral_sp_v) equal
line tobilateral_sp_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==5, normal percent
cumul tobilateral if cand==1 & party==5, gen(tobilateral_sp_c) equal
line tobilateral_sp_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==5, discrete freq by(cand, title("SP"))
twoway line tobilateral_sp_c tobilateral_sp_v tobilateral, sort lpattern(dash solid) title("SP")

integ(tobilateral_sp_c tobilateral)
integ(tobilateral_sp_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==5 & knowint==0, gen(tobilateral_sp_v_0) equal
integ(tobilateral_sp_v_0 tobilateral)
cumul tobilateral if cand==0 & party==5 & knowint==1, gen(tobilateral_sp_v_1) equal
integ(tobilateral_sp_v_1 tobilateral)

*GPS
sum tobilateral_C if T9a==5
sum tobilateral_V if W2_3_f11800main6==6
ttesti 256	1.855469	0.5588937 721	1.0638	1.088491

histogram tobilateral if cand==0 & party==6, normal percent
cumul tobilateral if cand==0 & party==6, gen(tobilateral_gps_v) equal
line tobilateral_gps_v tobilateral if cand==0, sort

histogram tobilateral if cand==1 & party==6, normal percent
cumul tobilateral if cand==1 & party==6, gen(tobilateral_gps_c) equal
line tobilateral_gps_c tobilateral if cand==1, sort

twoway histogram tobilateral if party==6, discrete freq by(cand, title("GPS"))
twoway line tobilateral_gps_c tobilateral_gps_v tobilateral, sort lpattern(dash solid) title("GPS")

integ(tobilateral_gps_c tobilateral)
integ(tobilateral_gps_v tobilateral)

*knowint
cumul tobilateral if cand==0 & party==6 & knowint==0, gen(tobilateral_gps_v_0) equal
integ(tobilateral_gps_v_0 tobilateral)
cumul tobilateral if cand==0 & party==6 & knowint==1, gen(tobilateral_gps_v_1) equal
integ(tobilateral_gps_v_1 tobilateral)

*************************
* COHESION BILLION
*************************

* rearrange variable (original categories, same direction C and V)
tab W1_f15642
gen W1_f15642_rec=W1_f15642
recode W1_f15642_rec (1=4) (2=3) (3=2) (4=1)

tab C10
gen C10_rec=C10
recode C10_rec (1=4) (2=3) (3=2) (4=1)

gen cohesion=.
replace cohesion=W1_f15642_rec if W2_3_f11800main6!=. & cand==0
replace cohesion=C10_rec if cand==1
tab cohesion cand

*overall
histogram cohesion if cand==0, normal percent
cumul cohesion if cand==0 [aweight=weight_p], gen(overall_cohesion_v) equal
line overall_cohesion_v cohesion if cand==0, sort

histogram cohesion if cand==1, normal percent
cumul cohesion if cand==1 [aweight=T16], gen (overall_cohesion_c) equal
line overall_cohesion_c cohesion if cand==1, sort

twoway histogram cohesion, discrete freq by(cand, title("Overall")) 
twoway line overall_cohesion_c overall_cohesion_v cohesion, sort lpattern(dash solid) title("Overall")

integ(overall_cohesion_c cohesion) 
integ(overall_cohesion_v cohesion) 

*knowint
cumul cohesion if cand==0 & knowint==0 [aweight=weight_p], gen(overall_cohesion_v_0) equal
integ(overall_cohesion_v_0 cohesion) 
cumul cohesion if cand==0 & knowint==1 [aweight=weight_p], gen(overall_cohesion_v_1) equal
integ(overall_cohesion_v_1 cohesion)

*Histogram "cohesion billion" across all parties
twoway histogram cohesion, discrete freq by(party cand) 

*SVP
sum cohesion_C if T9a==4 
sum cohesion_V if W2_3_f11800main6==1
ttesti 204	-1.779412	0.5113179 672	-1.06994	1.131919

histogram cohesion if cand==0 & party==1, normal percent
cumul cohesion if cand==0 & party==1, gen(cohesion_svp_v) equal
line cohesion_svp_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==1, normal percent
cumul cohesion if cand==1 & party==1, gen(cohesion_svp_c) equal
line cohesion_svp_c cohesion if cand==1, sort

twoway histogram cohesion if party==1, discrete freq by(cand, title("SVP"))
twoway line cohesion_svp_c cohesion_svp_v cohesion, sort lpattern(dash solid) title("SVP")ylabel(0(.2)1)

integ(cohesion_svp_v cohesion) 
integ(cohesion_svp_c cohesion) 

*knowint
cumul cohesion if cand==0 & party==1 & knowint==0, gen(cohesion_svp_v_0) equal
integ(cohesion_svp_v_0 cohesion) 
cumul cohesion if cand==0 & party==1 & knowint==1, gen(cohesion_svp_v_1) equal
integ(cohesion_svp_v_1 cohesion)

*FDP
sum cohesion_C if T9a==1
sum cohesion_V if W2_3_f11800main6==2
ttesti 214	0.2757009	1.357873 637	0.1302983	1.364524

histogram cohesion if cand==0 & party==2, normal percent
cumul cohesion if cand==0 & party==2, gen(cohesion_fdp_v) equal
line cohesion_fdp_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==2, normal percent
cumul cohesion if cand==1 & party==2, gen(cohesion_fdp_c) equal
line cohesion_fdp_c cohesion if cand==1, sort

twoway histogram cohesion if party==2, discrete freq by(cand, title("FDP"))
twoway line cohesion_fdp_c cohesion_fdp_v cohesion, sort lpattern(dash solid) title("FDP")

integ(cohesion_fdp_v cohesion) 
integ(cohesion_fdp_c cohesion) 

*knowint
cumul cohesion if cand==0 & party==2 & knowint==0, gen(cohesion_fdp_v_0) equal
integ(cohesion_fdp_v_0 cohesion) 
cumul cohesion if cand==0 & party==2 & knowint==1, gen(cohesion_fdp_v_1) equal
integ(cohesion_fdp_v_1 cohesion)

*CVP
sum cohesion_C if T9a==2
sum cohesion_V if W2_3_f11800main6==3
ttesti 354    .4124294    1.296962 355    .3183099    1.249894 

histogram cohesion if cand==0 & party==3, normal percent
cumul cohesion if cand==0 & party==3, gen(cohesion_cvp_v) equal
line cohesion_cvp_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==3, normal percent
cumul cohesion if cand==1 & party==3, gen(cohesion_cvp_c) equal
line cohesion_cvp_c cohesion if cand==1, sort

twoway histogram cohesion if party==3, discrete freq by(cand, title("CVP"))
twoway line cohesion_cvp_c cohesion_cvp_v cohesion, sort lpattern(dash solid) title("CVP")

integ(cohesion_cvp_v cohesion) 
integ(cohesion_cvp_c cohesion) 

*knowint
cumul cohesion if cand==0 & party==3 & knowint==0, gen(cohesion_cvp_v_0) equal
integ(cohesion_cvp_v_0 cohesion) 
cumul cohesion if cand==0 & party==3 & knowint==1, gen(cohesion_cvp_v_1) equal
integ(cohesion_cvp_v_1 cohesion)

*GLP
sum cohesion_C if T9a==6
sum cohesion_V if W2_3_f11800main6==4
ttesti 239	1.083682	1.156506 436	0.5	1.310436

histogram cohesion if cand==0 & party==4, normal percent
cumul cohesion if cand==0 & party==4, gen(cohesion_glp_v) equal
line cohesion_glp_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==4, normal percent
cumul cohesion if cand==1 & party==4, gen(cohesion_glp_c) equal
line cohesion_glp_c cohesion if cand==1, sort

twoway histogram cohesion if party==4, discrete freq by(cand, title("GLP"))
twoway line cohesion_glp_c cohesion_glp_v cohesion, sort lpattern(dash solid) title("GLP")

integ(cohesion_glp_v cohesion) 
integ(cohesion_glp_c cohesion) 

*knowint
cumul cohesion if cand==0 & party==4 & knowint==0, gen(cohesion_glp_v_0) equal
integ(cohesion_glp_v_0 cohesion) 
cumul cohesion if cand==0 & party==4 & knowint==1, gen(cohesion_glp_v_1) equal
integ(cohesion_glp_v_1 cohesion)

*SP
sum cohesion_C if T9a==3
sum cohesion_V if W2_3_f11800main6==5
ttesti 308	1.522727	0.8247809 767	0.8474576	1.202235

histogram cohesion if cand==0 & party==5, normal percent
cumul cohesion if cand==0 & party==5, gen(cohesion_sp_v) equal
line cohesion_sp_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==5, normal percent
cumul cohesion if cand==1 & party==5, gen(cohesion_sp_c) equal
line cohesion_sp_c cohesion if cand==1, sort

twoway histogram cohesion if party==5, discrete freq by(cand, title("SP"))
twoway line cohesion_sp_c cohesion_sp_v cohesion, sort lpattern(dash solid) title("SP")

integ(cohesion_sp_v cohesion) 
integ(cohesion_sp_c cohesion)

*knowint
cumul cohesion if cand==0 & party==5 & knowint==0, gen(cohesion_sp_v_0) equal
integ(cohesion_sp_v_0 cohesion) 
cumul cohesion if cand==0 & party==5 & knowint==1, gen(cohesion_sp_v_1) equal
integ(cohesion_sp_v_1 cohesion) 

*GPS
sum cohesion_C if T9a==5
sum cohesion_V if W2_3_f11800main6==6
ttesti 258	1.46124	0.8039601 718	0.7409471	1.230605

histogram cohesion if cand==0 & party==6, normal percent
cumul cohesion if cand==0 & party==6, gen(cohesion_gps_v) equal
line cohesion_gps_v cohesion if cand==0, sort

histogram cohesion if cand==1 & party==6, normal percent
cumul cohesion if cand==1 & party==6, gen(cohesion_gps_c) equal
line cohesion_gps_c cohesion if cand==1, sort

twoway histogram cohesion if party==6, discrete freq by(cand, title("GPS"))
twoway line cohesion_gps_c cohesion_gps_v cohesion, sort lpattern(dash solid) title("GPS")

integ(cohesion_gps_v cohesion) 
integ(cohesion_gps_c cohesion) 

*knowint
cumul cohesion if cand==0 & party==6 & knowint==0, gen(cohesion_gps_v_0) equal
integ(cohesion_gps_v_0 cohesion) 
cumul cohesion if cand==0 & party==6 & knowint==1, gen(cohesion_gps_v_1) equal
integ(cohesion_gps_v_1 cohesion)

*************************************************************
* INSTITUTIONAL FRAMEWORK AGREEMENT VS. ACCOMPANYING MEASURES
*************************************************************

* rearrange variable (original categories, same direction C and V)
tab W1_f15641
tab C9

gen toinsta=.
replace toinsta=W1_f15641 if W2_3_f11800main6!=. & cand==0
replace toinsta=C9 if cand==1
tab toinsta cand

*overall
histogram toinsta if cand==0, normal percent
cumul toinsta if cand==0 [aweight=weight_p], gen(overall_toinsta_v) equal
line overall_toinsta_v toinsta if cand==0, sort

histogram toinsta if cand==1, normal percent
cumul toinsta if cand==1 [aweight=T16], gen (overall_toinsta_c) equal
line overall_toinsta_c toinsta if cand==1, sort

twoway histogram toinsta, discrete freq by(cand, title("Overall")) 
twoway line overall_toinsta_c overall_toinsta_v toinsta, sort lpattern(dash solid) title("Overall")

integ(overall_toinsta_c toinsta) 
integ(overall_toinsta_v toinsta) 

*knowint
cumul toinsta if cand==0 & knowint==0 [aweight=weight_p], gen(overall_toinsta_v_0) equal
integ(overall_toinsta_v_0 toinsta) 
cumul toinsta if cand==0 & knowint==1 [aweight=weight_p], gen(overall_toinsta_v_1) equal
integ(overall_toinsta_v_1 toinsta)

*Histogram "cohesion billion" across all parties
twoway histogram toinsta, discrete freq by(party cand)

*SVP
sum toinsta_C if T9a==4 
sum toinsta_V if W2_3_f11800main6==1
ttesti 200	-1.655	0.661941 660	-0.9378788	1.044135

histogram toinsta if cand==0 & party==1, normal percent
cumul toinsta if cand==0 & party==1, gen(toinsta_svp_v) equal
line toinsta_svp_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==1, normal percent
cumul toinsta if cand==1 & party==1, gen(toinsta_svp_c) equal
line toinsta_svp_c toinsta if cand==1, sort

twoway histogram toinsta if party==1, discrete freq by(cand, title("SVP"))
twoway line toinsta_svp_c toinsta_svp_v toinsta, sort lpattern(dash solid) title("SVP")

integ(toinsta_svp_v toinsta) 
integ(toinsta_svp_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==1 & knowint==0, gen(toinsta_svp_v_0) equal
integ(toinsta_svp_v_0 toinsta) 
cumul toinsta if cand==0 & party==1 & knowint==1, gen(toinsta_svp_v_1) equal
integ(toinsta_svp_v_1 toinsta)

*FDP
sum toinsta_C if T9a==1
sum toinsta_V if W2_3_f11800main6==2
ttesti 208	1.009615	1.183585 630	0.1126984	1.35038

histogram toinsta if cand==0 & party==2, normal percent
cumul toinsta if cand==0 & party==2, gen(toinsta_fdp_v) equal
line toinsta_fdp_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==2, normal percent
cumul toinsta if cand==1 & party==2, gen(toinsta_fdp_c) equal
line toinsta_fdp_c toinsta if cand==1, sort

twoway histogram toinsta if party==2, discrete freq by(cand, title("FDP"))
twoway line toinsta_fdp_c toinsta_fdp_v toinsta, sort lpattern(dash solid) title("FDP") ylabel(0(.2)1)

integ(toinsta_fdp_v toinsta) 
integ(toinsta_fdp_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==2 & knowint==0, gen(toinsta_fdp_v_0) equal
integ(toinsta_fdp_v_0 toinsta) 
cumul toinsta if cand==0 & party==2 & knowint==1, gen(toinsta_fdp_v_1) equal
integ(toinsta_fdp_v_1 toinsta)

*CVP
sum toinsta_C if T9a==2
sum toinsta_V if W2_3_f11800main6==3
ttesti 353	0.0311615	1.355395 348	-0.137931	1.253674

histogram toinsta if cand==0 & party==3, normal percent
cumul toinsta if cand==0 & party==3, gen(toinsta_cvp_v) equal
line toinsta_cvp_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==3, normal percent
cumul toinsta if cand==1 & party==3, gen(toinsta_cvp_c) equal
line toinsta_cvp_c toinsta if cand==1, sort

twoway histogram toinsta if party==3, discrete freq by(cand, title("CVP"))
twoway line toinsta_cvp_c toinsta_cvp_v toinsta, sort lpattern(dash solid) title("CVP")

integ(toinsta_cvp_v toinsta) 
integ(toinsta_cvp_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==3 & knowint==0, gen(toinsta_cvp_v_0) equal
integ(toinsta_cvp_v_0 toinsta) 
cumul toinsta if cand==0 & party==3 & knowint==1, gen(toinsta_cvp_v_1) equal
integ(toinsta_cvp_v_1 toinsta)

*GLP
sum toinsta_C if T9a==6
sum toinsta_V if W2_3_f11800main6==4
ttesti 238	1.273109	1.077675 429	0.3030303	1.261032

histogram toinsta if cand==0 & party==4, normal percent
cumul toinsta if cand==0 & party==4, gen(toinsta_glp_v) equal
line toinsta_glp_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==4, normal percent
cumul toinsta if cand==1 & party==4, gen(toinsta_glp_c) equal
line toinsta_glp_c toinsta if cand==1, sort

twoway histogram toinsta if party==4, discrete freq by(cand, title("GLP"))
twoway line toinsta_glp_c toinsta_glp_v toinsta, sort lpattern(dash solid) title("GLP") ylabel(0(.2)1)

integ(toinsta_glp_v toinsta) 
integ(toinsta_glp_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==4 & knowint==0, gen(toinsta_glp_v_0) equal
integ(toinsta_glp_v_0 toinsta) 
cumul toinsta if cand==0 & party==4 & knowint==1, gen(toinsta_glp_v_1) equal
integ(toinsta_glp_v_1 toinsta)

*SP
sum toinsta_C if T9a==3
sum toinsta_V if W2_3_f11800main6==5
ttesti 310	-0.8903226	1.267302 757	-0.2417437	1.332719

histogram toinsta if cand==0 & party==5, normal percent
cumul toinsta if cand==0 & party==5, gen(toinsta_sp_v) equal
line toinsta_sp_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==5, normal percent
cumul toinsta if cand==1 & party==5, gen(toinsta_sp_c) equal
line toinsta_sp_c toinsta if cand==1, sort

twoway histogram toinsta if party==5, discrete freq by(cand, title("SP"))
twoway line toinsta_sp_c toinsta_sp_v toinsta, sort lpattern(dash solid) title("SP")

integ(toinsta_sp_v toinsta) 
integ(toinsta_sp_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==5 & knowint==0, gen(toinsta_sp_v_0) equal
integ(toinsta_sp_v_0 toinsta) 
cumul toinsta if cand==0 & party==5 & knowint==1, gen(toinsta_sp_v_1) equal
integ(toinsta_sp_v_1 toinsta)

*GPS
sum toinsta_C if T9a==5
sum toinsta_V if W2_3_f11800main6==6
ttesti 252	-0.6666667	1.220672 705	-0.2241135	1.299361

histogram toinsta if cand==0 & party==6, normal percent
cumul toinsta if cand==0 & party==6, gen(toinsta_gps_v) equal
line toinsta_gps_v toinsta if cand==0, sort

histogram toinsta if cand==1 & party==6, normal percent
cumul toinsta if cand==1 & party==6, gen(toinsta_gps_c) equal
line toinsta_gps_c toinsta if cand==1, sort

twoway histogram toinsta if party==6, discrete freq by(cand, title("GPS"))
twoway line toinsta_gps_c toinsta_gps_v toinsta, sort lpattern(dash solid) title("GPS")

integ(toinsta_gps_v toinsta) 
integ(toinsta_gps_c toinsta) 

*knowint
cumul toinsta if cand==0 & party==6 & knowint==0, gen(toinsta_gps_v_0) equal
integ(toinsta_gps_v_0 toinsta) 
cumul toinsta if cand==0 & party==6 & knowint==1, gen(toinsta_gps_v_1) equal
integ(toinsta_gps_v_1 toinsta)

*************************
* EU MEMBERSHIP
*************************

* rearrange variable (original categories, same direction C and V)
* alternative (recode such as we don't have to calculate the integral of 0 for SVP!)
tab W1_f15430
gen W1_f15430_rec=W1_f15430
recode W1_f15430_rec (1=1) (2=1.75) (3=2.5) (4=3.25) (5=4)

tab S57
gen S57_rec=S57
recode S57_rec (1=4) (2=3) (3=2) (4=1)

gen EU=.
replace EU=W1_f15430_rec if W2_3_f11800main6!=. & cand==0
replace EU=S57_rec if cand==1
tab EU cand

*overall
histogram EU if cand==0, normal percent
cumul EU if cand==0 [aweight=weight_p], gen(overall_EU_v) equal
line overall_EU_v EU if cand==0, sort

histogram EU if cand==1, normal percent
cumul EU if cand==1 [aweight=T16], gen (overall_EU_c) equal
line overall_EU_c EU if cand==1, sort

twoway histogram EU, discrete freq by(cand, title("Overall")) 
twoway line overall_EU_c overall_EU_v EU, sort lpattern(dash solid) title("Overall")

integ(overall_EU_c EU) 
integ(overall_EU_v EU) 

*knowint
cumul EU if cand==0 & knowint==0 [aweight=weight_p], gen(overall_EU_v_0) equal
integ(overall_EU_v_0 EU) 
cumul EU if cand==0 & knowint==1 [aweight=weight_p], gen(overall_EU_v_1) equal
integ(overall_EU_v_1 EU) 

*Histogram "EU membership" across all parties
twoway histogram EU, discrete freq by(party cand) 

*SVP
sum EUmember_C if T9a==4
sum EUmember_V if W2_3_f11800main6==1
ttesti 175	-2	0 679	-1.506627	0.7078575

histogram EU if cand==0 & party==1, normal percent
cumul EU if cand==0 & party==1, gen(EU_svp_v) equal
line EU_svp_v EU if cand==0, sort

histogram EU if cand==1 & party==1, normal percent
cumul EU if cand==1 & party==1, gen(EU_svp_c) equal
line EU_svp_c EU if cand==1, sort

twoway histogram EU if party==1, discrete freq by(cand, title("SVP"))
twoway line EU_svp_c EU_svp_v EU, sort lpattern(dash solid) title("SVP")

integ(EU_svp_v EU) 
integ(EU_svp_c EU) 

*knowint
cumul EU if cand==0 & party==1 & knowint==0, gen(EU_svp_v_0) equal
integ(EU_svp_v_0 EU) 
cumul EU if cand==0 & party==1 & knowint==1, gen(EU_svp_v_1) equal
integ(EU_svp_v_1 EU) 

*FDP
sum EUmember_C if T9a==1
sum EUmember_V if W2_3_f11800main6==2
ttesti 214	-1.845794	0.5729063 652	-0.7960123	1.042764

histogram EU if cand==0 & party==2, normal percent
cumul EU if cand==0 & party==2, gen(EU_fdp_v) equal
line EU_fdp_v EU if cand==0, sort

histogram EU if cand==1 & party==2, normal percent
cumul EU if cand==1 & party==2, gen(EU_fdp_c) equal
line EU_fdp_c EU if cand==1, sort

twoway histogram EU if party==2, discrete freq by(cand, title("FDP"))
twoway line EU_fdp_c EU_fdp_v EU, sort lpattern(dash solid) title("FDP")

integ(EU_fdp_v EU) 
integ(EU_fdp_c EU) 

*knowint
cumul EU if cand==0 & party==2 & knowint==0, gen(EU_fdp_v_0) equal
integ(EU_fdp_v_0 EU) 
cumul EU if cand==0 & party==2 & knowint==1, gen(EU_fdp_v_1) equal
integ(EU_fdp_v_1 EU) 

*CVP
sum EUmember_C if T9a==2
sum EUmember_V if W2_3_f11800main6==3
ttesti 326	-1.656442	0.8181056 363	-0.7438017	1.042168

histogram EU if cand==0 & party==3, normal percent
cumul EU if cand==0 & party==3, gen(EU_cvp_v) equal
line EU_cvp_v EU if cand==0, sort

histogram EU if cand==1 & party==3, normal percent
cumul EU if cand==1 & party==3, gen(EU_cvp_c) equal
line EU_cvp_c EU if cand==1, sort

twoway histogram EU if party==3, discrete freq by(cand, title("CVP"))
twoway line EU_cvp_c EU_cvp_v EU, sort lpattern(dash solid) title("CVP")

integ(EU_cvp_v EU) 
integ(EU_cvp_c EU) 

*knowint
cumul EU if cand==0 & party==3 & knowint==0, gen(EU_cvp_v_0) equal
integ(EU_cvp_v_0 EU) 
cumul EU if cand==0 & party==3 & knowint==1, gen(EU_cvp_v_1) equal
integ(EU_cvp_v_1 EU) 

*GLP
sum EUmember_C if T9a==6
sum EUmember_V if W2_3_f11800main6==4
ttesti 238	-0.987395	1.297453 440	-0.4318182	1.125349

histogram EU if cand==0 & party==4, normal percent
cumul EU if cand==0 & party==4, gen(EU_glp_v) equal
line EU_glp_v EU if cand==0, sort

histogram EU if cand==1 & party==4, normal percent
cumul EU if cand==1 & party==4, gen(EU_glp_c) equal
line EU_glp_c EU if cand==1, sort

twoway histogram EU if party==4, discrete freq by(cand, title("GLP"))
twoway line EU_glp_c EU_glp_v EU, sort lpattern(dash solid) title("GLP")

integ(EU_glp_v EU) 
integ(EU_glp_c EU) 

*knowint
cumul EU if cand==0 & party==4 & knowint==0, gen(EU_glp_v_0) equal
integ(EU_glp_v_0 EU) 
cumul EU if cand==0 & party==4 & knowint==1, gen(EU_glp_v_1) equal
integ(EU_glp_v_1 EU) 

*SP
sum EUmember_C if T9a==3
sum EUmember_V if W2_3_f11800main6==5
ttesti 304	0.2039474	1.452613 772	0.1049223	1.142563

histogram EU if cand==0 & party==5, normal percent
cumul EU if cand==0 & party==5, gen(EU_sp_v) equal
line EU_sp_v EU if cand==0, sort

histogram EU if cand==1 & party==5, normal percent
cumul EU if cand==1 & party==5, gen(EU_sp_c) equal
line EU_sp_c EU if cand==1, sort

twoway histogram EU if party==5, discrete freq by(cand, title("SP"))
twoway line EU_sp_c EU_sp_v EU, sort lpattern(dash solid) title("SP")

integ(EU_sp_v EU) 
integ(EU_sp_c EU) 

*knowint
cumul EU if cand==0 & party==5 & knowint==0, gen(EU_sp_v_0) equal
integ(EU_sp_v_0 EU) 
cumul EU if cand==0 & party==5 & knowint==1, gen(EU_sp_v_1) equal
integ(EU_sp_v_1 EU) 

*GPS
sum EUmember_C if T9a==5
sum EUmember_V if W2_3_f11800main6==6
ttesti 255	-0.1803922	1.463065 730	-0.2109589	1.137654

histogram EU if cand==0 & party==6, normal percent
cumul EU if cand==0 & party==6, gen(EU_gps_v) equal
line EU_gps_v EU if cand==0, sort

histogram EU if cand==1 & party==6, normal percent
cumul EU if cand==1 & party==6, gen(EU_gps_c) equal
line EU_gps_c EU if cand==1, sort

twoway histogram EU if party==6, discrete freq by(cand, title("GPS"))
twoway line EU_gps_c EU_gps_v EU, sort lpattern(dash solid) title("GPS")

integ(EU_gps_v EU) 
integ(EU_gps_c EU) 

*knowint
cumul EU if cand==0 & party==6 & knowint==0, gen(EU_gps_v_0) equal
integ(EU_gps_v_0 EU) 
cumul EU if cand==0 & party==6 & knowint==1, gen(EU_gps_v_1) equal
integ(EU_gps_v_1 EU) 

********************************************************************************
* Hypothesis 2: In detail (descriptive statistics for Online Appendix)
********************************************************************************

*** bil SVP
sum disfrom0_tobilateral_C if T9a==4
sum disfrom0_tobilateral_V if W2_3_f11800main6==1
ttesti 175	1.731429	0.4444882 675	1.466667	0.4992576

*** cohesion SVP
sum disfrom0_cohesion_C if T9a==4 
sum disfrom0_cohesion_V if W2_3_f11800main6==1 
ttesti 204	1.808824	0.3941951 672	1.474702	0.4997316

*** insta SVP
sum disfrom0_toinsta_C if T9a==4
sum disfrom0_toinsta_V if W2_3_f11800main6==1
ttesti 200	1.725	0.4476348 660	1.322727	0.467874

*** member SVP
sum disfrom0_EUmember_C if T9a==4 
sum disfrom0_EUmember_V if W2_3_f11800main6==1 
ttesti 175	2	0 679	1.547865	0.6123055

*** bil FDP
sum disfrom0_tobilateral_C if T9a==1
sum disfrom0_tobilateral_V if W2_3_f11800main6==2
ttesti 214	1.771028	0.4211563 649	1.362096	0.4809769

*** cohesion FDP
sum disfrom0_cohesion_C if T9a==1
sum disfrom0_cohesion_V if W2_3_f11800main6==2
ttesti 214	1.303738	0.4609493 637	1.291994	0.4550367

*** insta FDP
sum disfrom0_toinsta_C if T9a==1
sum disfrom0_toinsta_V if W2_3_f11800main6==2
ttesti 208	1.471154	0.5003715 630	1.277778	0.4482591

*** member FDP
sum disfrom0_EUmember_C if T9a==1
sum disfrom0_EUmember_V if W2_3_f11800main6==2
ttesti 214	1.911215	0.2851001 652	1.108896	0.7003054

*** bil CVP
sum disfrom0_tobilateral_C if T9a==2
sum disfrom0_tobilateral_V if W2_3_f11800main6==3
ttesti 326	1.714724	0.45224 360	1.3	0.4588954

*** cohesion CVP
sum disfrom0_cohesion_C if T9a==2
sum disfrom0_cohesion_V if W2_3_f11800main6==3
ttesti 354	1.282486	0.4508456 355	1.219718	0.4146402

*** insta CVP
sum disfrom0_toinsta_C if T9a==2
sum disfrom0_toinsta_V if W2_3_f11800main6==3
ttesti 353	1.27762	0.4484608 348	1.195402	0.397081

*** member CVP
sum disfrom0_EUmember_C if T9a==2
sum disfrom0_EUmember_V if W2_3_f11800main6==3
ttesti 326	1.803681	0.3978232 363	1.096419	0.6598705

*** bil GLP
sum disfrom0_tobilateral_C if T9a==6
sum disfrom0_tobilateral_V if W2_3_f11800main6==4
ttesti 238	1.89916	0.3017518 433	1.459584	0.4989404

*** cohesion GLP
sum disfrom0_cohesion_C if T9a==6
sum disfrom0_cohesion_V if W2_3_f11800main6==4
ttesti 239	1.502092	0.5010449 436	1.321101	0.4674358

*** insta GLP
sum disfrom0_toinsta_C if T9a==6
sum disfrom0_toinsta_V if W2_3_f11800main6==4
ttesti 238	1.592437	0.4924167 429	1.226107	0.4187978

*** member GLP
sum disfrom0_EUmember_C if T9a==6
sum disfrom0_EUmember_V if W2_3_f11800main6==4
ttesti 238	1.55042	0.4984997 440	0.9954545	0.6783185

*** bil SP
sum disfrom0_tobilateral_C if T9a==3
sum disfrom0_tobilateral_V if W2_3_f11800main6==5
ttesti 304	1.947368	0.2236651 769	1.469441	0.4993901

*** cohesion SP
sum disfrom0_cohesion_C if T9a==3
sum disfrom0_cohesion_V if W2_3_f11800main6==5
ttesti 308	1.665584	0.4725535 767	1.387223	0.4874332

*** insta SP
sum disfrom0_toinsta_C if T9a==3
sum disfrom0_toinsta_V if W2_3_f11800main6==5
ttesti 310	1.464516	0.4995457 757	1.277411	0.448017

*** member SP
sum disfrom0_EUmember_C if T9a==3
sum disfrom0_EUmember_V if W2_3_f11800main6==5
ttesti 304	1.381579	0.486575 772	0.9443005	0.6508549

*** bil GPS
sum disfrom0_tobilateral_C if T9a==5
sum disfrom0_tobilateral_V if W2_3_f11800main6==6
ttesti 256	1.917969	0.2749499 721	1.43828	0.4965205

*** cohesion GPS
sum disfrom0_cohesion_C if T9a==5
sum disfrom0_cohesion_V if W2_3_f11800main6==6
ttesti 258	1.593023	0.4922253 718	1.35376	0.4784693

*** insta GPS
sum disfrom0_toinsta_C if T9a==5
sum disfrom0_toinsta_V if W2_3_f11800main6==6
ttesti 252	1.309524	0.4632173 705	1.24539	0.4306238

*** member GPS
sum disfrom0_EUmember_C if T9a==5
sum disfrom0_EUmember_V if W2_3_f11800main6==6
ttesti 255	1.388235	0.488307 730	0.9506849	0.6586188

********* MORE DESCRIPTIVES FOR ONLINE APPENDIX
********* (DISTRIBUTION OF VOTER AND CANDIDATE ANSWERS)

* voters
* bilaterals
tab tobilateral W2_3_f11800main6 if cand==0, row
tab2xl tobilateral W2_3_f11800main6 if cand==0 using bil_v, row(2) col(2) replace percentage
tab tobilateral if W2_3_f11800main6!=. [aweight=weight_p]
* cohesion
tab cohesion W2_3_f11800main6 if cand==0, row
tab2xl cohesion W2_3_f11800main6 if cand==0 using cohesion_v, row(2) col(2) replace percentage
tab cohesion if W2_3_f11800main6!=. [aweight=weight_p]
* insta
tab toinsta W2_3_f11800main6 if cand==0, row
tab2xl toinsta W2_3_f11800main6 if cand==0 using insta_v, row(2) col(2) replace percentage
tab toinsta if W2_3_f11800main6!=. [aweight=weight_p]
* eu membership
tab EU W2_3_f11800main6 if cand==0, row
tab2xl EU W2_3_f11800main6 if cand==0 using EU_v, row(2) col(2) replace percentage
tab EU if W2_3_f11800main6!=. [aweight=weight_p]

* candidates
* bilaterals
tab tobilateral party if cand==1, row
tab2xl tobilateral party if cand==1 using bil_c, row(2) col(2) replace percentage
tab tobilateral if cand==1 [aweight=T16]
* cohesion
tab cohesion party if cand==1, row
tab2xl cohesion party if cand==1 using cohesion_c, row(2) col(2) replace percentage
tab cohesion if cand==1  [aweight=T16]
* insta
tab toinsta party if cand==1, row
tab2xl toinsta party if cand==1 using insta_c, row(2) col(2) replace percentage
tab toinsta if cand==1 [aweight=T16]
* eu membership
tab EU party if cand==1, row
tab2xl EU party if cand==1 using EU_c, row(2) col(2) replace percentage
tab EU if cand==1 [aweight=T16]

********************************************************************************
* Hypothesis 3: Is voter-candidate congruence (many-to-many) on European 
* integration questions lower for parties situated further from the political 
* centre on the left-right dimension than for centrist parties?
********************************************************************************

* All many-to-many congruence values for the different groups (voters and candidates) across the parties can be found in the following Excel file: "Congruence measures.xlsx"

* H3
* Delete all the data/open new (empty) dataset and insert sheet "congr" from "Congruence measures.xlsx"
edit

* Statistical test for H3 (see results in Table 2 in the paper)
ttest mtom_congruence, by(lr_pole)

* some additional tests
ttest mtom_congruence, by(econlr_pole)
ttest mtom_congruence, by(galtan_pole)
ttest mtom_congruence, by(eu_pole)

* Additional analyses for Online Appendix: Are politically more sophisticated voters more congruent with elite opinions than politically less sophisticated voters?
* Delete all the data/open new (empty) dataset and insert sheet "knowint" from "Congruence measures.xlsx"
edit

* Statistical test for additional analyses (see results in Table B19 in the Online Appendix)
ttest mtom_congruence, by(knowint)
